package com.mm.filter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

//@WebFilter:将一个类声明为过滤器
@WebFilter(filterName = "webFilter", urlPatterns = "/*")
public class CustomWebFilter implements Filter {
    private static Logger logger = LoggerFactory.getLogger(CustomWebFilter.class);

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        logger.info("---------->>>过滤器_init");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        logger.info("---------->>>过滤器_doFilter");
        filterChain.doFilter(servletRequest,servletResponse);
    }

    @Override
    public void destroy() {
        logger.info("---------->>>过滤器_destroy");
    }
}
